﻿
namespace Patterns4Net.PatternEnforcer.Core.Patterns
{
    using Patterns4Net.Core.CecilExtensions;
    using Patterns4Net.Core.Patterns;
    using Patterns4Net.PatternEnforcer.Core.ClassCheckers;
    using Patterns4Net.PatternEnforcer.Core.MethodCheckers;

    [PatternCheckerExport(typeof(NullObject))]
    public class NullObjectChecker : FluentPatternChecker<NullObject>
    {
        public NullObjectChecker()
        {
            this.Type(pattern => pattern.TargetType)
                .Check(
                    type => type.BaseType.IsEqual(typeof(object)) == false || type.Interfaces.Count > 0,
                    type => string.Format(ErrorMessages.NullObjectShouldBeSubclassOrImplementInterface, type.Name))
                .Checker(new EverythingIsOverridden(checkSystemObjectMethods: false))
                .Methods().Checker<HasMinimalImplementation>();
        }
    }
}
